View Javadoc

1   /*
2    * Created on 09-Feb-2005
3    *
4    * @todo To change the template for this generated file go to
5    * Window - Preferences - Java - Code Style - Code Templates
6    */
7   package uk.ac.roe.antigen.textcomponents;
8   
9   import java.io.DataInputStream;
10  import java.io.IOException;
11  import java.io.Reader;
12  import java.io.StringReader;
13  import java.util.logging.Logger;
14  
15  import uk.ac.roe.antigen.builder.InfoDisplay;
16  import uk.ac.roe.antigen.utils.HtmlToTextParser;
17  
18  /***
19   * @author jdt
20   */
21  public class TextInfoDisplay implements InfoDisplay {
22      /***
23       * Logger for this class
24       */
25      private static final Logger logger = Logger.getLogger(TextInfoDisplay.class.getName());
26  
27  
28  	private String message;
29  
30  	/***
31  	 * @param message
32  	 */
33  	public TextInfoDisplay(String message) {
34  
35  
36  		this.message = message;
37  
38  	}
39  
40  	/* (non-Javadoc)
41  	 * @see uk.ac.roe.antigen.builder.InfoDisplay#showAndWaitForResponse()
42  	 */
43  	public void showAndWaitForResponse() {
44  
45  
46  		HtmlToTextParser parser = new HtmlToTextParser();
47          Reader reader = new StringReader(message);
48          try {
49  			String plainText = parser.parse(reader);
50              System.out.println(plainText);
51  		} catch (IOException e) {
52  			logger.warning("showAndWaitForResponse()"+ e.getMessage());
53  			System.out.println("Error showing Info\n");
54  		}
55          System.out.println("\n---Press Return to Continue---");
56          try {
57  			new DataInputStream(System.in).readLine();
58  		} catch (IOException e1) {
59  			logger.warning(e1.getMessage());
60  		}
61  
62  
63  	}
64  
65  	public static void main(String[] args) {
66  		new TextInfoDisplay("<h1>This is a test</h1>Test text").showAndWaitForResponse();
67      }
68  }